package com.sds.book.dubbo.consumer;

import com.sds.book.dubbo.api.IHelloService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * 使用 dubbo 提供的 @Reference 注解来获得一个远程代理对象
 */
@SpringBootApplication
public class ConsumerApp {

    @Reference(url = "dubbo://localhost:20880/com.sds.book.dubbo.api.IHelloService")
    private IHelloService helloService;

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApp.class, args);
    }

    @Bean
    public ApplicationRunner runner() {
        return args -> System.out.println(helloService.sayHello("sds"));
    }

}
